package com.example.harmonyosproject.Utils;

import net.sourceforge.pinyin4j.PinyinHelper;

public class PinyinUtils {
    public static char getFirstLetter(String chinese) {
    if (chinese == null || chinese.isEmpty()) {
        return '#'; // 返回#表示非中文字符
    }

    char firstChar = chinese.charAt(0);
    if (Character.toString(firstChar).matches("[\\u4E00-\\u9FA5]+")) {
        String pinyin = PinyinHelper.toHanyuPinyinStringArray(firstChar)[0];
        return pinyin.charAt(0);
    } else {
        return Character.toLowerCase(firstChar);
    }
    }
}
